#ifndef KC_RULE_H__KC
#define KC_RULE_H__KC

#include <vector>
#include "cond/Symbol.h"
#include "../mime/data/Message.h"

namespace kc_sf
{
	enum ActionType
	{
		UndefinedAction = -1,
		Delete = 0,
		Quarantine,
		Pass,
		Forward,
		ActionTypesNr
	};

	std::string ActionTypeToString( ActionType action );

	class Rule
	{
		public:

			Rule( const std::string &expr_str,
				ActionType action,
				int priority );

			Rule( const Rule &rule );
			Rule & operator =( const Rule &rule );
			~Rule();

			void addCondition( Logic::Symbol *condition );
			void buildRpnExpression();

			bool eval( const Message &msg ) const;
			ActionType getAction() const { return r_action; }
			int getPriority() const { return r_priority; }
			std::string getExpression() const { return r_expression; }

		private:

			std::vector <Logic::Symbol *> r_conditions;
			std::string r_expression;
			std::string r_rpn_expression;
			ActionType r_action;
			int r_priority;
	};
}

#endif /* KC_RULE_H__KC */
